package nl.cwi.arne.generator.tools;

import nl.cwi.arne.Network;
import nl.cwi.arne.generator.NetworkActivationGenerator;
import nl.cwi.arne.generator.mcrl2.ArneMCRL2Translator;
import nl.cwi.arne.util.NetworkActivationBuffer;

import org.eclipse.equinox.app.IApplicationContext;

public class NetworkActivationGeneratorTool extends AbstractGeneratorTool {
	
	/*
	 * (non-Javadoc)
	 * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
	 */
	@Override
	public Object start(IApplicationContext context) throws Exception {
		
		// Load the network:
		Network network = loadNetwork(context);
		network.setCheckEquivalence(true);
		network.setCheckModalFormula(false);
		network.setCheckStableRegions(false);

		// MCRL2 translator:
		ArneMCRL2Translator translator = new ArneMCRL2Translator();
		translator.setStartFromZeroChange(true);
		
		// Activation generator:
		NetworkActivationGenerator generator = new NetworkActivationGenerator();
		generator.setMCRL2Options(getMCRL2Options());
		generator.setOutputStream(System.out);
		generator.setTranslator(translator);
				
		NetworkActivationBuffer buffer = new NetworkActivationBuffer(network);
		generator.generate(network, buffer, monitor);
		
		network.eResource().save(null);
		
		return null;
		
	}
		
}
